//@author A0094511L
///@class OutputManager
///@Description This class converts the structure received from EntriesManager into properly formatted strings for
//				the GUI to make use of. The strings are formatted through the addition of HTML tags, and returned 
//				as a concatenated strings of html string that can be recognized by GUI's QTextEdit

#pragma once
#include <QString>
#include <vector>
#include <cassert>
#include "CommonUtils.h"
#include "CommonEnum.h"

class OutputManager{

public:

	//@brief Constructor that takes in oututFromEntriesManager
	OutputManager(vector <vector<CommonEnum::ReturnString>>);

	//@default constructor
	~OutputManager(void);

	static const QString SECTION_HEADER_TITLE_FRONT_TAG;
	static const QString SECTION_HEADER_TITLE_BACK_TAG;
	static const QString SECTION_HEADER_DATE_FRONT_TAG;
	static const QString SECTION_HEADER_DATE_BACK_TAG;
	static const QString SECTION_HEADER_ONLYONE_BACK_TAG;

	static const QString OVERDUE_HEADER_TITLE_FRONT_TAG;
	static const QString OVERDUE_HEADER_TITLE_BACK_TAG;

	static const QString TODAY_HEADER_TITLE_FRONT_TAG;
	static const QString TODAY_HEADER_TITLE_BACK_TAG;
	static const QString TODAY_HEADER_DATE_FRONT_TAG;
	static const QString TODAY_HEADER_DATE_BACK_TAG;

	static const QString SECTION_COMPONENT_NAME_FRONT_TAG_NORMAL;
	static const QString SECTION_COMPONENT_NAME_BACK_TAG_NORMAL;
	static const QString SECTION_COMPONENT_DATEORTIME_FRONT_TAG_NORMAL;
	static const QString SECTION_COMPONENT_DATEORTIME_END_TAG_NORMAL;
	static const QString SECTION_COMPONENT_ONLYONE_BACK_TAG_NORMAL;

	static const QString SECTION_COMPONENT_NAME_FRONT_TAG_ADDITION;
	static const QString SECTION_COMPONENT_NAME_BACK_TAG_ADDITION;
	static const QString SECTION_COMPONENT_DATEORTIME_FRONT_TAG_ADDITION;
	static const QString SECTION_COMPONENT_DATEORTIME_END_TAG_ADDITION;
	static const QString SECTION_COMPONENT_ONLYONE_BACK_TAG_ADDITION;

	static const QString SECTION_COMPONENT_NAME_FRONT_TAG_CLASH;
	static const QString SECTION_COMPONENT_NAME_BACK_TAG_CLASH;
	static const QString SECTION_COMPONENT_DATEORTIME_FRONT_TAG_CLASH;
	static const QString SECTION_COMPONENT_DATEORTIME_END_TAG_CLASH;
	static const QString SECTION_COMPONENT_ONLYONE_BACK_TAG_CLASH;

	static const QString SECTION_COMPONENT_NAME_FRONT_TAG_DONE;
	static const QString SECTION_COMPONENT_NAME_BACK_TAG_DONE;
	static const QString SECTION_COMPONENT_DATEORTIME_FRONT_TAG_DONE;
	static const QString SECTION_COMPONENT_DATEORTIME_END_TAG_DONE;
	static const QString SECTION_COMPONENT_ONLYONE_BACK_TAG_DONE;
	
	//@brief accessor function for formatted string
	QString getFormattedString();

private:

	//@brief Function adds HTML tags to section header of overdue only
	QString appendOverdueHeaderTags(pair<string,string> entry);
	
	QString appendTodayHeaderTags(pair<string,string> entry);

	//@brief Function adds HTML tags to section headers, for example, today, tmr, future
	QString appendSectionHeaderTags(pair<string, string>);

	//@brief Function adds HTML tags to normal entries
	QString appendNormalComponentTags(pair<string, string>);

	//@brief Function adds HTML tags to newly added entries
	QString appendAdditionComponentTags(pair<string, string>);

	//@brief Function adds HTML tags to clashing entries
	QString appendClashComponentTags(pair<string, string>);

	//@brief Function adds HTML tags to completed entries
	QString appendDoneComponentTags(pair<string, string>);
	
	//Function converts the vector of each section to a formatted string
	QString convertEachSectionToStr(vector<CommonEnum::ReturnString> section);

	//Function append tags individually for each data point according to its type
	QString appendTagsForEachData(CommonEnum::ReturnString data);

	//@brief Function appends Html Tags to two data, tags used depends on the type of HTML required, either the different headers,
	//		 or different component types
	//		 Appends Front and Back Tags to 1st Data Member: Name/Title
	//       Appends Front and Back Tags to 2nd Data Member: Date
	//@post  Returns a HTML formatted string for 2 data members
	QString combineTagsForTwoData(QString, string, QString, QString, string, QString);

	//@brief Function appends Html Tags to one data, tags used depends on the type of HTML required, either the different headers, 
	//		 or different component types
	//		 Appends Front and Back Tags to 1st Data Member: Name/Title
	//@post  Returns a HTML formatted string for 2 data members
	QString combineTagsForOneData(QString, string, QString, QString);

	//@brief Function converts the vector of vector of pair of strings to the correct format. Function does so
	//		 by calling all the above functions to append html tags, depending on the format required as stated
	//		 in the enum provided by entriesManager
	void convertToOutputStr();

	//private member to store all the strings in the constructor
	vector<vector<CommonEnum::ReturnString>> _vectOfVectOfStrings;
	
	//private member of formatted html string
	QString _formattedOutput;
};
